<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import jwtDecode from 'jwt-decode';

export default {
  name: 'app',
  created() {
    //重新获取登录用户的信息
    this.getAdminInfo()
  },
  methods: {
    getAdminInfo() {
      if (localStorage.getItem('adminToken')) {
        //在token中获取用户信息
        const decoded = jwtDecode(localStorage.getItem('adminToken'));
        //todo：做一个接口，验证这个用户的信息是否存在
        console.log('app decoded=>', decoded);
        //获取到adminInfo，保存到vuex
        this.$store.dispatch('setAdminInfo', decoded);
      }
    }
  }
}
</script>

<style lang="less">
#app {
  height: 100vh;
  color: #2c3e50;
  overflow: hidden;
}

* {
  padding: 0;
  margin: 0;
  list-style: none;
}
</style>
